C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Release\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) REGFILE(.\Release\Sample_DrvRTC.ORC) BROWSE INC
                    -DIR(..\..\..\..\C51SIS\C51;..\..\..\Include\Driver) DEBUG OBJECTEXTEND CODE TABS(2) OBJECT(.\Release\main.obj)

line level    source

   1          /**************************************************************************//**
   2           * @file           main.c
   3           * @version        V1.0
   4           * $Revision:      1 $
   5           * $Date:          2017/01/04 $
   6           * @brief          Main function
   7           * @Author         Jeffrey Kang
   8           * @ContactInfo    chkang@esmt.com.tw
   9           *
  10           * @note
  11           *
  12           * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
  13           * All rights reserved.
  14           *
  15           ******************************************************************************/
  16          
  17          
  18          #include <REG52.h>
  19          #include "system_FE81001.h"
  20          
  21          
  22          static volatile unsigned char clb_data[3] = {0x11, 0x22, 0x33};
  23          static volatile unsigned char cnt = 0;
  24          
  25          
  26          /**
  27           * @brief       delay function
  28           *
  29           * @param       None
  30           *
  31           * @return      None
  32           *
  33           * @details     1. 
  34           */
  35          void delay (void)
  36          {
  37   1        unsigned int i;
  38   1        
  39   1        for( i = 0 ; i < 200 ; i++ ){}
  40   1      }
  41          
  42          
  43          /**
  44           * @brief       I2CSISR function
  45           *
  46           * @param       None
  47           *
  48           * @return      None
  49           *
  50           * @details     1. 
  51           */
  52          const void RTCISR (void) interrupt ISR_RTC
  53          {
  54   1        unsigned short int_stat = RTC->rtc_stat;
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 2   

  55   1        
  56   1        /* alarm interrupt */
  57   1        if ((int_stat & 0x04) == 0x04){
  58   2          RTC->rtc_stat = 0x04;
  59   2          
  60   2          PD3 = ~PD3; // Toggle LED_G2
  61   2          
  62   2        }
  63   1        /* day interrupt */
  64   1        if ((int_stat & 0x08) == 0x08){
  65   2          RTC->rtc_stat = 0x08;
  66   2          
  67   2        }
  68   1        
  69   1        /* hour interrupt */
  70   1        if ((int_stat & 0x10) == 0x10){
  71   2          RTC->rtc_stat = 0x10;
  72   2          
  73   2        }
  74   1        
  75   1        /* min interrupt */
  76   1        if ((int_stat & 0x20) == 0x20){
  77   2          RTC->rtc_stat = 0x20;
  78   2          
  79   2          PD2 = ~PD2; // Toggle LED_R1
  80   2        } 
  81   1        
  82   1        /* sec interrupt */
  83   1        if ((int_stat & 0x40) == 0x40){
  84   2          RTC->rtc_stat = 0x40;
  85   2          
  86   2          PD1 = ~PD1; // Toggle LED_G1
  87   2        }
  88   1        
  89   1        
  90   1        /* enable global interrupt */
  91   1        INTC->int_gmask = 0x01;
  92   1      }
  93          
  94          
  95          /**
  96           * @brief       RTCConfig function
  97           *
  98           * @param       None
  99           *
 100           * @return      None
 101           *
 102           * @details     1. 
 103           */
 104          void RTCConfig()
 105          { 
 106   1          /* set current time */
 107   1        RTC->cnt_sec  = 0x1A;
 108   1        RTC->cnt_min  = 0x14;
 109   1        RTC->cnt_hour = 0x10;
 110   1        RTC->cnt_day  = 0x00;
 111   1        
 112   1        /* set alarm time */
 113   1        RTC->alm_sec  = 0x1C;
 114   1        RTC->alm_min  = 0x14;
 115   1        RTC->alm_hour = 0x10;
 116   1        
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 3   

 117   1        /* enable rtc interrupt */
 118   1        RTC->rtc_ctrl = 0x75;               // 0, sec = 1, min = 0, hour = 0, day = 0, alarm_int = 1, alarm_wakeu
             -p = 0, rtc_en = 1
 119   1        
 120   1          /* enable global interrupt */
 121   1        INTC->int_gmask = 0x01;
 122   1        
 123   1        /* wait write_done */
 124   1        while(!RTC->write_done){}
 125   1      }
 126          
 127          
 128          /**
 129           * @brief       IOConfig function
 130           *
 131           * @param       None
 132           *
 133           * @return      None
 134           *
 135           * @details     1. 
 136           */
 137          void IOConfig()
 138          {
 139   1        /* enable GPIO clock */
 140   1        PORT_PAPBPCPD_Clock_Enable(); // enable GPIOA GPIOB GPIOC GPIOD clock
 141   1        
 142   1        /* Set PC7 input as button */
 143   1        PORT_SetPCInput(BIT7);
 144   1      
 145   1        /* Set PD1. ,PD2.,PD3 output */
 146   1        PORT_SetPDPushPull(BIT1 | BIT2 | BIT3 );  
 147   1      }
 148          
 149          
 150          /**
 151           * @brief       CLKConfig function
 152           *
 153           * @param       None
 154           *
 155           * @return      None
 156           *
 157           * @details     1. 
 158           */
 159          void CLKConfig()
 160          {
 161   1        /* rtc clock source select */
 162   1        Set_RTC_ClockSource(Low_speed_oscillator);
 163   1        
 164   1        /* enable RTC clock */
 165   1        En_RTC_clk();
 166   1        
 167   1        /* wait LSRC stable */
 168   1        while((CLKC->clkstb & 0x04) != 0x04){}
 169   1        
 170   1        /* wait clock selection ready */
 171   1        delay();
 172   1      }
 173          
 174          
 175          /**
 176           * @brief       main function
 177           *
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 4   

 178           * @param       None
 179           *
 180           * @return      None
 181           *
 182           * @details     1. 
 183           */
 184          int main (void)
 185          {
 186   1        CLKConfig();
 187   1        IOConfig();
 188   1        
 189   1        RTCConfig();
 190   1        
 191   1        PD1=1; //LED_G1 Off
 192   1        PD2=1; //LED_R Off
 193   1        PD3=1; //LED_G2 Off
 194   1        
 195   1        
 196   1        
 197   1        while(1)
 198   1        {
 199   2      //    if( Get_PCx_input(7) == 0)   // PC7  = 0 , button down
 200   2      //      {
 201   2      //          PD2 = 0 ; //LED_R On
 202   2      //      }
 203   2      //      else
 204   2      //      {
 205   2      //          PD2 = 1 ; //LED_R Off
 206   2      //      }
 207   2        }
 208   1      }
 209          
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 5   

ASSEMBLY LISTING OF GENERATED OBJECT CODE


             ; FUNCTION delay (BEGIN)
                                           ; SOURCE LINE # 35
                                           ; SOURCE LINE # 36
                                           ; SOURCE LINE # 39
0000 750000      R     MOV     i,#00H
0003 750000      R     MOV     i+01H,#00H
0006         ?C0001:
0006 C3                CLR     C
0007 E500        R     MOV     A,i+01H
0009 94C8              SUBB    A,#0C8H
000B E500        R     MOV     A,i
000D 9400              SUBB    A,#00H
000F 500A              JNC     ?C0004
0011 0500        R     INC     i+01H
0013 E500        R     MOV     A,i+01H
0015 7002              JNZ     ?C0021
0017 0500        R     INC     i
0019         ?C0021:
0019 80EB              SJMP    ?C0001
                                           ; SOURCE LINE # 40
001B         ?C0004:
001B 22                RET     
             ; FUNCTION delay (END)

             ; FUNCTION RTCISR (BEGIN)
0000 C0E0              PUSH    ACC
0002 C083              PUSH    DPH
0004 C082              PUSH    DPL
0006 C0D0              PUSH    PSW
0008 75D000            MOV     PSW,#00H
000B C006              PUSH    AR6
000D C007              PUSH    AR7
                                           ; SOURCE LINE # 52
                                           ; SOURCE LINE # 54
000F 90EA08            MOV     DPTR,#0EA08H
0012 E0                MOVX    A,@DPTR
0013 FF                MOV     R7,A
0014 7E00              MOV     R6,#00H
0016 8E00        R     MOV     int_stat,R6
0018 8F00        R     MOV     int_stat+01H,R7
                                           ; SOURCE LINE # 57
001A E500        R     MOV     A,int_stat+01H
001C 30E213            JNB     ACC.2,?C0005
                                           ; SOURCE LINE # 58
001F 90EA08            MOV     DPTR,#0EA08H
0022 7404              MOV     A,#04H
0024 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 60
0025 90E048            MOV     DPTR,#0E048H
0028 E0                MOVX    A,@DPTR
0029 FF                MOV     R7,A
002A EF                MOV     A,R7
002B F4                CPL     A
002C FF                MOV     R7,A
002D 90E048            MOV     DPTR,#0E048H
0030 EF                MOV     A,R7
0031 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 62
0032         ?C0005:
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 6   

                                           ; SOURCE LINE # 64
0032 E500        R     MOV     A,int_stat+01H
0034 30E306            JNB     ACC.3,?C0006
                                           ; SOURCE LINE # 65
0037 90EA08            MOV     DPTR,#0EA08H
003A 7408              MOV     A,#08H
003C F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 67
003D         ?C0006:
                                           ; SOURCE LINE # 70
003D E500        R     MOV     A,int_stat+01H
003F 30E406            JNB     ACC.4,?C0007
                                           ; SOURCE LINE # 71
0042 90EA08            MOV     DPTR,#0EA08H
0045 7410              MOV     A,#010H
0047 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 73
0048         ?C0007:
                                           ; SOURCE LINE # 76
0048 E500        R     MOV     A,int_stat+01H
004A 30E513            JNB     ACC.5,?C0008
                                           ; SOURCE LINE # 77
004D 90EA08            MOV     DPTR,#0EA08H
0050 7420              MOV     A,#020H
0052 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 79
0053 90E047            MOV     DPTR,#0E047H
0056 E0                MOVX    A,@DPTR
0057 FF                MOV     R7,A
0058 EF                MOV     A,R7
0059 F4                CPL     A
005A FF                MOV     R7,A
005B 90E047            MOV     DPTR,#0E047H
005E EF                MOV     A,R7
005F F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 80
0060         ?C0008:
                                           ; SOURCE LINE # 83
0060 E500        R     MOV     A,int_stat+01H
0062 30E613            JNB     ACC.6,?C0009
                                           ; SOURCE LINE # 84
0065 90EA08            MOV     DPTR,#0EA08H
0068 7440              MOV     A,#040H
006A F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 86
006B 90E046            MOV     DPTR,#0E046H
006E E0                MOVX    A,@DPTR
006F FF                MOV     R7,A
0070 EF                MOV     A,R7
0071 F4                CPL     A
0072 FF                MOV     R7,A
0073 90E046            MOV     DPTR,#0E046H
0076 EF                MOV     A,R7
0077 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 87
0078         ?C0009:
                                           ; SOURCE LINE # 91
0078 90E400            MOV     DPTR,#0E400H
007B 7401              MOV     A,#01H
007D F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 92
007E D007              POP     AR7
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 7   

0080 D006              POP     AR6
0082 D0D0              POP     PSW
0084 D082              POP     DPL
0086 D083              POP     DPH
0088 D0E0              POP     ACC
008A 32                RETI    
             ; FUNCTION RTCISR (END)

             ; FUNCTION RTCConfig (BEGIN)
                                           ; SOURCE LINE # 104
                                           ; SOURCE LINE # 105
                                           ; SOURCE LINE # 107
0000 90EA00            MOV     DPTR,#0EA00H
0003 741A              MOV     A,#01AH
0005 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 108
0006 90EA01            MOV     DPTR,#0EA01H
0009 7414              MOV     A,#014H
000B F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 109
000C 90EA02            MOV     DPTR,#0EA02H
000F 7410              MOV     A,#010H
0011 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 110
0012 90EA03            MOV     DPTR,#0EA03H
0015 E4                CLR     A
0016 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 113
0017 90EA04            MOV     DPTR,#0EA04H
001A 741C              MOV     A,#01CH
001C F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 114
001D 90EA05            MOV     DPTR,#0EA05H
0020 7414              MOV     A,#014H
0022 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 115
0023 90EA06            MOV     DPTR,#0EA06H
0026 7410              MOV     A,#010H
0028 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 118
0029 90EA07            MOV     DPTR,#0EA07H
002C 7475              MOV     A,#075H
002E F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 121
002F 90E400            MOV     DPTR,#0E400H
0032 7401              MOV     A,#01H
0034 F0                MOVX    @DPTR,A
0035         ?C0011:
                                           ; SOURCE LINE # 124
0035 90EA09            MOV     DPTR,#0EA09H
0038 E0                MOVX    A,@DPTR
0039 FF                MOV     R7,A
003A EF                MOV     A,R7
003B 60F8              JZ      ?C0011
                                           ; SOURCE LINE # 125
003D 22                RET     
             ; FUNCTION RTCConfig (END)

             ; FUNCTION IOConfig (BEGIN)
                                           ; SOURCE LINE # 137
                                           ; SOURCE LINE # 138
                                           ; SOURCE LINE # 140
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 8   

0000 90E205            MOV     DPTR,#0E205H
0003 E0                MOVX    A,@DPTR
0004 FF                MOV     R7,A
0005 EF                MOV     A,R7
0006 44F0              ORL     A,#0F0H
0008 FF                MOV     R7,A
0009 EF                MOV     A,R7
000A F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 143
000B 90E032            MOV     DPTR,#0E032H
000E E0                MOVX    A,@DPTR
000F FF                MOV     R7,A
0010 EF                MOV     A,R7
0011 547F              ANL     A,#07FH
0013 FF                MOV     R7,A
0014 EF                MOV     A,R7
0015 F0                MOVX    @DPTR,A
0016 90E031            MOV     DPTR,#0E031H
0019 E0                MOVX    A,@DPTR
001A FF                MOV     R7,A
001B EF                MOV     A,R7
001C 547F              ANL     A,#07FH
001E FF                MOV     R7,A
001F EF                MOV     A,R7
0020 F0                MOVX    @DPTR,A
0021 90E030            MOV     DPTR,#0E030H
0024 E0                MOVX    A,@DPTR
0025 FF                MOV     R7,A
0026 EF                MOV     A,R7
0027 547F              ANL     A,#07FH
0029 FF                MOV     R7,A
002A EF                MOV     A,R7
002B F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 146
002C 90E044            MOV     DPTR,#0E044H
002F E0                MOVX    A,@DPTR
0030 FF                MOV     R7,A
0031 EF                MOV     A,R7
0032 54F1              ANL     A,#0F1H
0034 FF                MOV     R7,A
0035 EF                MOV     A,R7
0036 F0                MOVX    @DPTR,A
0037 90E043            MOV     DPTR,#0E043H
003A E0                MOVX    A,@DPTR
003B FF                MOV     R7,A
003C EF                MOV     A,R7
003D 54F1              ANL     A,#0F1H
003F FF                MOV     R7,A
0040 EF                MOV     A,R7
0041 F0                MOVX    @DPTR,A
0042 90E042            MOV     DPTR,#0E042H
0045 E0                MOVX    A,@DPTR
0046 FF                MOV     R7,A
0047 EF                MOV     A,R7
0048 440E              ORL     A,#0EH
004A FF                MOV     R7,A
004B EF                MOV     A,R7
004C F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 147
004D 22                RET     
             ; FUNCTION IOConfig (END)

C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 9   

             ; FUNCTION CLKConfig (BEGIN)
                                           ; SOURCE LINE # 159
                                           ; SOURCE LINE # 160
                                           ; SOURCE LINE # 162
0000 90E202            MOV     DPTR,#0E202H
0003 E0                MOVX    A,@DPTR
0004 FF                MOV     R7,A
0005 EF                MOV     A,R7
0006 54F7              ANL     A,#0F7H
0008 FF                MOV     R7,A
0009 90E202            MOV     DPTR,#0E202H
000C EF                MOV     A,R7
000D F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 165
000E 90E204            MOV     DPTR,#0E204H
0011 E0                MOVX    A,@DPTR
0012 FF                MOV     R7,A
0013 EF                MOV     A,R7
0014 4410              ORL     A,#010H
0016 FF                MOV     R7,A
0017 EF                MOV     A,R7
0018 F0                MOVX    @DPTR,A
0019         ?C0015:
                                           ; SOURCE LINE # 168
0019 90E201            MOV     DPTR,#0E201H
001C E0                MOVX    A,@DPTR
001D FF                MOV     R7,A
001E EF                MOV     A,R7
001F 5404              ANL     A,#04H
0021 FF                MOV     R7,A
0022 7E00              MOV     R6,#00H
0024 EF                MOV     A,R7
0025 6404              XRL     A,#04H
0027 4E                ORL     A,R6
0028 70EF              JNZ     ?C0015
                                           ; SOURCE LINE # 171
002A 120000      R     LCALL   delay
                                           ; SOURCE LINE # 172
002D 22                RET     
             ; FUNCTION CLKConfig (END)

             ; FUNCTION main (BEGIN)
                                           ; SOURCE LINE # 184
                                           ; SOURCE LINE # 185
                                           ; SOURCE LINE # 186
0000 120000      R     LCALL   CLKConfig
                                           ; SOURCE LINE # 187
0003 120000      R     LCALL   IOConfig
                                           ; SOURCE LINE # 189
0006 120000      R     LCALL   RTCConfig
                                           ; SOURCE LINE # 191
0009 90E046            MOV     DPTR,#0E046H
000C 7401              MOV     A,#01H
000E F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 192
000F 90E047            MOV     DPTR,#0E047H
0012 7401              MOV     A,#01H
0014 F0                MOVX    @DPTR,A
                                           ; SOURCE LINE # 193
0015 90E048            MOV     DPTR,#0E048H
0018 7401              MOV     A,#01H
001A F0                MOVX    @DPTR,A
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:25:09 PAGE 10  

001B         ?C0018:
                                           ; SOURCE LINE # 197
                                           ; SOURCE LINE # 198
                                           ; SOURCE LINE # 207
001B 80FE              SJMP    ?C0018
001D 22                RET     
             ; FUNCTION main (END)



MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    383    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
